function DrawPhase (Transfer, Color, figura, w,plantilla,unidades,fix)
    
    [z p konst]=zpkdata(Transfer);
        z=squeeze(cell2mat(z));
        p=squeeze(cell2mat(p));
    if fix
        
        if ~isempty(z)
            for k=1:length(z)
                if imag(z(k))>0
                    z(k)=1j*abs(imag(z(k)));
                else
                    z(k)=-1j*abs(imag(z(k)));
                end
            end
        end
    else
        if ~isempty(z)
            for k=1:length(z)
                z(k)=j*imag(z(k))-abs(imag(z(k)))/10000;
                
                
                
            end
        end
    end

        

    Transfer=konst*tf(poly(z),poly(p));
    [MAG,PHASE] = bode((Transfer),w);
    PHASE = squeeze (PHASE);
    kind= plantilla.tipodefiltro ; %(1 bajo, 2 altos, 3 pasabanda , 4 rechaza)
    
    
    switch kind
         case 1
            xlim(figura,[plantilla.wp/unidades/10,plantilla.wa/unidades*10]);

         case 2
            xlim(figura,[plantilla.wa/unidades/10,plantilla.wp/unidades*10]);
            

         case 3

            xlim(figura,[plantilla.wa(1)/unidades/10,plantilla.wa(2)/unidades*10]);
            

         otherwise
            xlim(figura,[plantilla.wp(1)/unidades/10,plantilla.wp(2)/unidades*10]);
            
    end
   % if kind~=4 || fix~=1
        acomoda=0;

        for k=1:size(PHASE)-1
            PHASE(k)=PHASE(k)+360*acomoda;
            if (PHASE(k+1)-PHASE(k))>300
                acomoda=acomoda-1;
            else if (PHASE(k +1)-PHASE(k))<-300
                acomoda=acomoda+1;
                end

            end
        end     
    %end
    
    if kind==4 && fix==1
        
       odd=0;
       if rem(length(z)/2,2)>0.1
            odd=1;
       end
       
       inicial=ceil(PHASE(1)/360);
       [z p k]=zpkdata(Transfer);
       z=squeeze(cell2mat(z));
       limite=abs(z(1));
       cantidad=length(z);
       
       for k=1:length(w)
               PHASE(k)=PHASE(k)-inicial*360;
           if w(k)> limite;
               PHASE(k)=PHASE(k)+cantidad*90+odd*180;
           end
       end
        
        
    end


     ylim(figura,[min(PHASE)-100,max(PHASE)+100]);
  
     
     set(figura,'XScale','log');
        
     semilogx(figura,w/unidades,PHASE,'Color',Color);

end